
<script type="text/javascript">

    function openMdoel(tag){
      $('#'+tag).modal('show');
    }


   function addData(){
	  var objTr =  $("#table-data").find("tbody").find('tr:first-child').clone(true);
      $(objTr).show();
      $(objTr).find('td').map(function(){
         var data_toggle  = $(this).attr('data-toggle');
         if(data_toggle == "text"){
            $(this).html('<input name="" value="" />');
         }else if(data_toggle == "operation"){
            $(this).html('<code><a onclick="saveData(this)" href="javascript:void(0);">保存</a></code><code><a onclick="deleteData(this)" href="javascript:void(0);">删除</a></code>');
         }
         /*else if(data_toggle == "number"){
            var number = $(this).html();
            $(this).html(number+1);
         }
         */
         else{
        	$(this).html('');
         }
      });
      objTr.prependTo($("#table-data").find('tbody'));
   }

   
   function editData(obj){
       var trObj = $(obj).parent().parent().parent();
       $(trObj).find("td[data-toggle]").map(function(){
            var data_toggle = $(this).attr('data-toggle');
            if(data_toggle == "text"){
                 var value =  $(this).html();
                 $(this).html("<input  value='"+value+"'/>");
            }
       });
   }

   function saveData(obj){
       var trObj = $(obj).parent().parent().parent();
       
       $(trObj).find('td').map(function(){
            
       });
   }

   function deleteData(obj){
	   
        $(obj).parent().parent().parent().remove();
        
   }
   
   function editSite(tag){
      
   }


  
   function addSite(tag){
	   
      $("#"+tag+"-title").html("<?php echo Fw::app()->i18n('add site'); ?>");
      
   }

   $(document).ready(function(){
	  
	});
   
</script>
<a class="btn btn-primary" onclick="addData()" data-toggle="modal" href="javascript:void(0)"  data-keyboard="false" data-backdrop="false" >添加网站</a>

<table id='table-data' class="table table-bordered table-striped">
     <thead>
        <tr>
          <th>编号</th>
          <th>描述</th>
          <th>创建时间</th>
          <th>操作</th>
       </tr>
     </thead>
     <tbody>
     <tr style="display:none">
         <td data-toggle='number'>
         </td>
         <td data-toggle='text'>
        </td>
        <td>
        </td>
        <td  data-toggle="operation">
            <code><a href="#" onclick="editData(this)">修改</a></code>
            <code><a href="#">保存</a></code>
            <code><a href="javascript:void(0);" onclick="deleteData(this)">删除</a></code>
        </td>
      </tr>
       <?php foreach($viewData as $key => $val){?>
       <tr >
         <td data-toggle='number'>
           <?php echo $val["site_id"]; ?>
         </td>
         <td data-toggle='text'>
           <?php echo $val["site_name"]; ?>
        </td>
        <td>
           <?php echo $val["createtime"]; ?>
        </td>
        <td  data-toggle="operation">
            <code><a   href="javascript:void(0);"  onclick="editData(this)">修改</a></code>
            <code><a   href="javascript:void(0);"  onclick="saveData(this)">保存</a></code>
            <code><a   href="javascript:void(0);"  onclick="deleteData(this)">删除</a></code>
        </td>
      </tr>
      <?php }?>
   </tbody>
</table>

